unit InfoF;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Bass, StdCtrls, TntStdCtrls, dll, Grids, TntGrids, functions, header;

type
  TInfo = class(TForm)
    TntEdit1: TTntEdit;
    Grid: TTntStringGrid;
    procedure FormCreate(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    procedure DoGrid;
  end;

var
  Info: TInfo;

implementation

uses Unit1;

{$R *.dfm}

procedure TInfo.DoGrid;
begin
  with Grid do
    begin
      ColWidths[0] := 147;
      ColWidths[1] := 175;

      Cells[0,0] := 'Stream Type';
      Cells[0,1] := 'Chanels';
      Cells[0,2] := 'Sample Rate';
      Cells[0,3] := 'File Size';
      Cells[0,4] := 'Duration';
      Cells[0,5] := 'Average BitRate';
      Cells[0,6] := 'Resolution';
    end;
end;

procedure TInfo.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  Action := caFree;
end;

procedure TInfo.FormCreate(Sender: TObject);
var
  info: BASS_CHANNELINFO;
  res: byte;
begin
  DoGrid;
  ActiveControl := nil;

  BASS_ChannelGetInfo(Form1.CurrentStream, info);

  Grid.Cells[1,1] := IntToStr(info.chans);
  Grid.Cells[1,2] := FloatToStr(info.freq) + ' kHz';
  Grid.Cells[1,3] := IntToStr(Form1.CS.FSize) + ' bytes';
  Grid.Cells[1,4] := PChar(SecToTime(Form1.PDB.GetSeconds(Form1.TrackIndex)));
  Grid.Cells[1,5] := IntToStr(Form1.CS.bitrate) + ' kb/s';

  if (info.flags and BASS_SAMPLE_8BITS) > 0 then
    res := 8
  else
    if (info.flags and BASS_SAMPLE_FLOAT) > 0 then
      res := 32
    else
      res := 16;

  Grid.Cells[1,6] := IntToStr(res) + 'bit';

  case info.ctype of
    BASS_CTYPE_STREAM_WAV: Grid.Cells[1,0] := 'Waveform audio (WAV)';
    BASS_CTYPE_STREAM_WAV_PCM: Grid.Cells[1,0] := 'Waveform audio (WAV PCM)';
    BASS_CTYPE_STREAM_WAV_FLOAT: Grid.Cells[1,0] := 'Waveform audio (WAV Float)';
    BASS_CTYPE_STREAM_OGG: Grid.Cells[1,0] := 'Ogg Vorbis';
    BASS_CTYPE_STREAM_MP1: Grid.Cells[1,0] := 'MPEG-1 Audio Layer 1 (MP1)';
    BASS_CTYPE_STREAM_MP2: Grid.Cells[1,0] := 'MPEG-1 Audio Layer 2 (MP2)';
    BASS_CTYPE_STREAM_MP3: Grid.Cells[1,0] := 'MPEG-1 Audio Layer 3 (MP3)';
    BASS_CTYPE_STREAM_MPC: Grid.Cells[1,0] := 'Musepack (MPC)';
    BASS_CTYPE_STREAM_AIFF: Grid.Cells[1,0] := 'Audio Interchange File Format (AIFF)';
    BASS_CTYPE_STREAM_FLAC: Grid.Cells[1,0] := 'Free Lossless Audio Codec (native FLAC)';
    BASS_CTYPE_STREAM_FLAC_OGG: Grid.Cells[1,0] := 'Free Lossless Audio Codec (Ogg FLAC)';
    BASS_CTYPE_STREAM_WMA: Grid.Cells[1,0] := 'Windows Media Audio (WMA)';
    BASS_CTYPE_STREAM_WMA_MP3: Grid.Cells[1,0] := 'Windows Media Audio (WMA)';
    BASS_CTYPE_STREAM_AAC: Grid.Cells[1,0] := 'Advanced Audio Coding (AAC)';
    BASS_CTYPE_STREAM_MP4: Grid.Cells[1,0] := 'MPEG-4 Part 14 (MP4)';
    BASS_CTYPE_STREAM_ALAC: Grid.Cells[1,0] := 'Apple Lossless Audio (ALAC)';
    else
      Grid.Cells[1,0] := 'Unknown';
  end;

  TntEdit1.Text := Form1.PDB.GetFileName(Form1.TrackIndex);
end;

end.
